package org.gd.hellojavacore.streams;

import java.io.*;

public class AppStream {

    public static void main(String ... args) {
        try {
            String fileName = "/home/dimka/test/report.html";
            OutputStream outputStream = new FileOutputStream(new File(fileName + "2"));
            InputStream inputStream = new FileInputStream(new File(fileName));
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            for(;;) {
                int b = inputStream.read();
                if(b == -1) {
                    break;
                }
                byteArrayOutputStream.write(b);
            }
            new ByteArrayOutputStream().writeTo(outputStream);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
